/**
 * @name Find Module Boundaries
 * @kind problem
 * @problem.severity info
 * @id cpp/find-module-boundaries
 * @description 识别模块边界，基于BUILD.gn文件路径
 */

import cpp

from Function f, File file
where f.getFile() = file
  // 排除标准库
  and not file.getRelativePath().matches("%/usr/%")
  and not file.getRelativePath().matches("%stdlib.h%")
select 
  f.getName() as functionName,
  f.getQualifiedName() as qualifiedName,
  file.getRelativePath() as filePath,
  // 从文件路径推断模块路径
  // 例如: foundation/arkui/napi/src/xxx.cpp -> foundation/arkui/napi
  regexpCapture(file.getRelativePath(), "^(.*?)/[^/]+$", 1) as modulePath,
  f.getLocation().getStartLine() as startLine

